package com.feifan.consumer.config;

import com.feifan.consumer.aop.SystemLogAspect;
import com.feifan.consumer.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.client.support.BasicAuthenticationInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: FinalProject
 * @author: Xiaofan
 * @createTime: 2021-08-04 20:19
 * @description: Functions of this class is 进行拦截器的配置
 **/
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private AuthenticationInterceptor authenticationInterceptor;//自定义的一个拦截器
    @Autowired
    private SystemLogAspect systemLogAspect;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //应用自己写的方法，通过拦截所有请求，然后判断是否有@SystemLog注解修饰，然后决定是否修饰
        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**");
        registry.addInterceptor(systemLogAspect).addPathPatterns("/**");
    }
}